{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "reflected-egyptian",
   "metadata": {},
   "outputs": [],
   "source": [
    "from code.ftquoteapi import quoteapi \n",
    "\n",
    "context = quoteapi()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "personalized-desire",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-03-01 18:03:47,349 [open_context_base.py] _socket_reconnect_and_wait_ready:255: Start connecting: host=127.0.0.1; port=11111;\n",
      "2021-03-01 18:03:47,352 [open_context_base.py] on_connected:344: Connected : conn_id=2; \n",
      "2021-03-01 18:03:47,356 [open_context_base.py] _handle_init_connect:445: InitConnect ok: conn_id=2; info={'server_version': 500, 'login_user_id': 716900, 'conn_id': 6772093993015514404, 'conn_key': '069F62ACD89290B9', 'conn_iv': 'DEF296745C67C683', 'keep_alive_interval': 10, 'is_encrypt': False};\n",
      "2021-03-01 18:03:47,390 [network_manager.py] work:366: Close: conn_id=2\n"
     ]
    }
   ],
   "source": [
    "context.init_context()\n",
    "ret, quote = context.get_market_snapshot(['SH.600000', 'HK.00700','US.FUTU'])\n",
    "context.closecontext()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "demanding-newport",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'行情权限不足'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "quote"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ignored-circle",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-03-01 18:04:06,286 [open_context_base.py] _socket_reconnect_and_wait_ready:255: Start connecting: host=127.0.0.1; port=11111;\n",
      "2021-03-01 18:04:06,289 [open_context_base.py] on_connected:344: Connected : conn_id=3; \n",
      "2021-03-01 18:04:06,293 [open_context_base.py] _handle_init_connect:445: InitConnect ok: conn_id=3; info={'server_version': 500, 'login_user_id': 716900, 'conn_id': 6772094072434899759, 'conn_key': 'F6837FACD89284D6', 'conn_iv': 'C45E6E0F5F67166C', 'keep_alive_interval': 10, 'is_encrypt': False};\n",
      "2021-03-01 18:04:06,301 [network_manager.py] work:366: Close: conn_id=3\n"
     ]
    }
   ],
   "source": [
    "context.init_context()\n",
    "ret, quote = context.get_market_snapshot(['US.FUTU'])\n",
    "context.closecontext()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
